<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>招商加盟详情 - 精品咖啡品牌</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome 图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <style>
        :root {
            --primary: #2c6ecb;
            --primary-light: #4a89dc;
            --secondary: #f6bb42;
            --success: #37bc9b;
            --danger: #da4453;
            --text-primary: #333333;
            --text-secondary: #656d78;
            --text-tertiary: #aab2bd;
            --bg-light: #f5f7fa;
            --bg-white: #ffffff;
            --border-light: #e6e9ed;
            --radius: 8px;
            --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-light);
            color: var(--text-primary);
            padding-top: 56px;
            padding-bottom: 60px;
        }
        
        /* 顶部导航 */
        .top-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 56px;
            background-color: var(--primary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 16px;
            z-index: 1000;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        
        .nav-title {
            font-size: 18px;
            font-weight: 600;
            color: white;
            text-align: center;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        
        .nav-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: none;
            border: none;
            color: white;
            font-size: 20px;
        }
        
        /* 轮播图 */
        .detail-carousel {
            position: relative;
            height: 220px;
            overflow: hidden;
        }
        
        .carousel-indicators {
            bottom: 10px;
        }
        
        .carousel-indicators [data-bs-target] {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.6);
            border: none;
        }
        
        .carousel-indicators .active {
            background-color: white;
        }
        
        .carousel-item img {
            height: 100%;
            object-fit: cover;
        }
        
        .carousel-count {
            position: absolute;
            top: 10px;
            right: 10px;
            background-color: rgba(0, 0, 0, 0.5);
            color: white;
            font-size: 12px;
            padding: 2px 8px;
            border-radius: 10px;
        }
        
        /* 详情内容 */
        .detail-content {
            background-color: var(--bg-white);
            padding: 16px;
            margin-bottom: 10px;
        }
        
        .detail-title {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 12px;
            line-height: 1.3;
        }
        
        .detail-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-bottom: 16px;
            font-size: 13px;
            color: var(--text-secondary);
        }
        
        .detail-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 16px;
        }
        
        .detail-tag {
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 12px;
            background-color: rgba(44, 110, 203, 0.1);
            color: var(--primary);
        }
        
        .detail-section {
            margin-bottom: 20px;
        }
        
        .section-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 10px;
            padding-left: 8px;
            border-left: 3px solid var(--primary);
        }
        
        .detail-text {
            font-size: 14px;
            line-height: 1.6;
            color: var(--text-primary);
            margin-bottom: 16px;
        }
        
        .feature-list {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 16px;
        }
        
        .feature-item {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            padding: 10px;
            background-color: var(--bg-light);
            border-radius: var(--radius);
        }
        
        .feature-icon {
            color: var(--primary);
            margin-top: 3px;
        }
        
        .feature-text {
            font-size: 13px;
            flex: 1;
        }
        
        /* 数据统计 */
        .stats-container {
            background-color: var(--bg-white);
            padding: 16px;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-around;
            text-align: center;
            border-bottom: 1px solid var(--border-light);
        }
        
        .stat-item {
            flex: 1;
        }
        
        .stat-value {
            font-size: 18px;
            font-weight: 600;
            color: var(--primary);
            margin-bottom: 4px;
        }
        
        .stat-label {
            font-size: 12px;
            color: var(--text-secondary);
        }
        
        /* 操作按钮 */
        .action-buttons {
            position: fixed;
            bottom: 60px;
            left: 0;
            right: 0;
            background-color: var(--bg-white);
            padding: 10px 16px;
            display: flex;
            gap: 10px;
            border-top: 1px solid var(--border-light);
            z-index: 900;
        }
        
        .action-btn {
            flex: 1;
            padding: 10px 0;
            border-radius: var(--radius);
            font-size: 14px;
            font-weight: 500;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            border: none;
        }
        
        .primary-btn {
            background-color: var(--primary);
            color: white;
        }
        
        .secondary-btn {
            background-color: var(--bg-light);
            color: var(--text-primary);
        }
        
        /* 留言区 */
        .comments-section {
            background-color: var(--bg-white);
            padding: 16px;
            margin-bottom: 80px;
        }
        
        .comments-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 16px;
        }
        
        .comments-title {
            font-size: 16px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .comments-count {
            color: var(--primary);
        }
        
        .sort-comments {
            font-size: 13px;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            gap: 4px;
            background: none;
            border: none;
        }
        
        .comment-input-container {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }
        
        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
            flex-shrink: 0;
        }
        
        .comment-input {
            flex: 1;
            padding: 10px 12px;
            border-radius: 20px;
            border: 1px solid var(--border-light);
            background-color: var(--bg-light);
            font-size: 14px;
        }
        
        .comment-list {
            margin-bottom: 20px;
        }
        
        .comment-item {
            display: flex;
            gap: 10px;
            margin-bottom: 16px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-light);
        }
        
        .comment-content {
            flex: 1;
        }
        
        .comment-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 6px;
        }
        
        .user-name {
            font-size: 13px;
            font-weight: 500;
        }
        
        .comment-time {
            font-size: 12px;
            color: var(--text-tertiary);
        }
        
        .comment-text {
            font-size: 14px;
            margin-bottom: 8px;
        }
        
        .comment-actions {
            display: flex;
            gap: 16px;
        }
        
        .comment-action {
            font-size: 12px;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            gap: 4px;
            background: none;
            border: none;
        }
        
        .comment-action.active {
            color: var(--danger);
        }
        
        .replies-container {
            margin-top: 12px;
            padding-left: 10px;
            border-left: 2px solid var(--border-light);
        }
        
        .reply-item {
            margin-bottom: 10px;
            padding: 8px;
            background-color: var(--bg-light);
            border-radius: var(--radius);
        }
        
        .reply-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 4px;
        }
        
        .reply-text {
            font-size: 13px;
            margin-bottom: 6px;
        }
        
        .reply-actions {
            display: flex;
            gap: 16px;
        }
        
        .reply-action {
            font-size: 11px;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            gap: 2px;
            background: none;
            border: none;
        }
        
        .reply-input-container {
            display: flex;
            gap: 8px;
            margin-top: 10px;
        }
        
        .reply-input {
            flex: 1;
            padding: 6px 10px;
            border-radius: 14px;
            border: 1px solid var(--border-light);
            font-size: 13px;
        }
        
        .reply-btn {
            padding: 6px 12px;
            border-radius: 14px;
            background-color: var(--primary);
            color: white;
            border: none;
            font-size: 13px;
        }
        
        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 60px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid var(--border-light);
            z-index: 1000;
        }
        
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--text-tertiary);
            font-size: 11px;
            gap: 4px;
            text-decoration: none;
            flex: 1;
        }
        
        .nav-item.active {
            color: var(--primary);
        }
        
        .nav-icon {
            font-size: 20px;
        }
        
        /* 提示消息 */
        .toast {
            position: fixed;
            bottom: 130px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 8px 16px;
            border-radius: 4px;
            z-index: 9999;
            font-size: 14px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .toast.show {
            opacity: 1;
        }
        
        /* 图片查看器 */
        .image-viewer {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: black;
            z-index: 2000;
            display: none;
            justify-content: center;
            align-items: center;
        }
        
        .image-viewer.active {
            display: flex;
        }
        
        .viewer-image {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
        }
        
        .close-viewer {
            position: absolute;
            top: 16px;
            right: 16px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: rgba(0, 0, 0, 0.5);
            color: white;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
        }
        
        .viewer-count {
            position: absolute;
            top: 16px;
            left: 16px;
            background-color: rgba(0, 0, 0, 0.5);
            color: white;
            font-size: 14px;
            padding: 4px 10px;
            border-radius: 12px;
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="top-nav">
        <button class="nav-btn" id="backBtn">
            <i class="fas fa-arrow-left"></i>
        </button>
        <div class="nav-title">招商加盟详情</div>
        <button class="nav-btn" id="shareBtn">
            <i class="fas fa-share-alt"></i>
        </button>
    </div>
    
    <!-- 轮播图 -->
    <div id="detailCarousel" class="carousel slide detail-carousel" data-bs-ride="carousel">
        <div class="carousel-indicators">
            <button type="button" data-bs-target="#detailCarousel" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
            <button type="button" data-bs-target="#detailCarousel" data-bs-slide-to="1" aria-label="Slide 2"></button>
            <button type="button" data-bs-target="#detailCarousel" data-bs-slide-to="2" aria-label="Slide 3"></button>
        </div>
        <div class="carousel-inner" id="carouselInner">
            <div class="carousel-item active">
                <img src="https://picsum.photos/id/292/800/400" class="d-block w-100" alt="咖啡店铺环境">
            </div>
            <div class="carousel-item">
                <img src="https://picsum.photos/id/431/800/400" class="d-block w-100" alt="咖啡产品展示">
            </div>
            <div class="carousel-item">
                <img src="https://picsum.photos/id/766/800/400" class="d-block w-100" alt="加盟店实拍">
            </div>
        </div>
        <div class="carousel-count" id="carouselCount">1/3</div>
    </div>
    
    <!-- 详情内容 -->
    <div class="detail-content">
        <h1 class="detail-title">精品咖啡品牌诚招加盟商，提供全套运营支持和培训</h1>
        
        <div class="detail-meta">
            <span><i class="fas fa-building" style="margin-right: 4px;"></i>醇香咖啡有限公司</span>
            <span><i class="fas fa-map-marker-alt" style="margin-right: 4px;"></i>全国招商</span>
            <span><i class="far fa-clock" style="margin-right: 4px;"></i>5小时前更新</span>
        </div>
        
        <div class="detail-tags">
            <span class="detail-tag">餐饮美食</span>
            <span class="detail-tag">20-50万</span>
            <span class="detail-tag">全程扶持</span>
            <span class="detail-tag">品牌保障</span>
        </div>
        
        <div class="detail-section">
            <h3 class="section-title">项目介绍</h3>
            <p class="detail-text">
                本精品咖啡品牌创立于2010年，专注于为消费者提供高品质咖啡体验。目前全国已有100+连锁门店，品牌影响力持续扩大。我们诚邀有创业梦想的投资者加入，共同开拓咖啡市场。
            </p>
            <p class="detail-text">
                加盟后，总部将提供全方位支持，包括店铺选址、装修设计、人员培训、运营指导、营销策划等，让您轻松开店，无忧经营。
            </p>
        </div>
        
        <div class="detail-section">
            <h3 class="section-title">加盟优势</h3>
            <div class="feature-list">
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">成熟品牌，市场认可度高</span>
                </div>
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">优质原料供应，保证产品品质</span>
                </div>
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">专业培训体系，快速上手</span>
                </div>
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">全方位运营支持，降低风险</span>
                </div>
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">强大营销团队，助力推广</span>
                </div>
                <div class="feature-item">
                    <i class="fas fa-check-circle feature-icon"></i>
                    <span class="feature-text">合理的利润空间，收益稳定</span>
                </div>
            </div>
        </div>
        
        <div class="detail-section">
            <h3 class="section-title">加盟条件</h3>
            <p class="detail-text">
                1. 认同品牌文化和经营理念，愿意接受总部统一管理<br>
                2. 具备一定的投资能力和风险意识<br>
                3. 拥有良好的商业信誉和人脉资源<br>
                4. 能够全身心投入店铺经营管理<br>
                5. 遵守品牌总部的各项规定和要求
            </p>
        </div>
        
        <div class="detail-section">
            <h3 class="section-title">加盟流程</h3>
            <p class="detail-text">
                1. 在线咨询或留言，获取加盟资料<br>
                2. 填写加盟申请表，总部审核<br>
                3. 审核通过后，实地考察总部及门店<br>
                4. 签订加盟合同，缴纳相关费用<br>
                5. 店铺选址、装修设计与施工<br>
                6. 人员招聘与培训<br>
                7. 设备安装、原料采购<br>
                8. 试营业及正式开业<br>
                9. 总部持续运营支持
            </p>
        </div>
    </div>
    
    <!-- 数据统计 -->
    <div class="stats-container">
        <div class="stat-item">
            <div class="stat-value">1.8k</div>
            <div class="stat-label">浏览量</div>
        </div>
        <div class="stat-item">
            <div class="stat-value">96</div>
            <div class="stat-label">咨询量</div>
        </div>
        <div class="stat-item">
            <div class="stat-value">32</div>
            <div class="stat-label">加盟店</div>
        </div>
        <div class="stat-item">
            <div class="stat-value">4.9</div>
            <div class="stat-label">好评率</div>
        </div>
    </div>
    
    <!-- 留言区 -->
    <div class="comments-section">
        <div class="comments-header">
            <h3 class="comments-title">
                <i class="far fa-comment"></i>
                加盟咨询 <span class="comments-count">(12)</span>
            </h3>
            <button class="sort-comments">
                <span>最新</span>
                <i class="fas fa-chevron-down"></i>
            </button>
        </div>
        
        <div class="comment-input-container">
            <img src="https://picsum.photos/id/64/100/100" alt="用户头像" class="user-avatar">
            <input type="text" class="comment-input" placeholder="我想了解加盟细节...">
        </div>
        
        <div class="comment-list">
            <!-- 评论1 -->
            <div class="comment-item">
                <img src="https://picsum.photos/id/91/100/100" alt="用户头像" class="user-avatar">
                <div class="comment-content">
                    <div class="comment-header">
                        <span class="user-name">咖啡爱好者</span>
                        <span class="comment-time">2小时前</span>
                    </div>
                    <p class="comment-text">请问在二线城市开一家店，大概需要多少投资？包含哪些费用？</p>
                    <div class="comment-actions">
                        <button class="comment-action">
                            <i class="far fa-thumbs-up"></i>
                            <span>12</span>
                        </button>
                        <button class="comment-action reply-btn">
                            <i class="far fa-reply"></i>
                            <span>回复</span>
                        </button>
                    </div>
                    
                    <!-- 回复 -->
                    <div class="replies-container">
                        <div class="reply-item">
                            <div class="reply-header">
                                <span class="user-name">醇香咖啡官方</span>
                                <span class="comment-time">1小时前</span>
                            </div>
                            <p class="reply-text">您好，二线城市投资大概在30-40万左右，包含加盟费、保证金、设备费、装修费等，具体可电话咨询详细了解。</p>
                            <div class="reply-actions">
                                <button class="reply-action">
                                    <i class="far fa-thumbs-up"></i>
                                    <span>5</span>
                                </button>
                                <button class="reply-action">
                                    <i class="far fa-reply"></i>
                                    <span>回复</span>
                                </button>
                            </div>
                        </div>
                        
                        <div class="reply-input-container">
                            <img src="https://picsum.photos/id/64/100/100" alt="用户头像" class="user-avatar" style="width: 28px; height: 28px;">
                            <input type="text" class="reply-input" placeholder="回复 @咖啡爱好者...">
                            <button class="reply-btn">回复</button>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 评论2 -->
            <div class="comment-item">
                <img src="https://picsum.photos/id/26/100/100" alt="用户头像" class="user-avatar">
                <div class="comment-content">
                    <div class="comment-header">
                        <span class="user-name">创业达人</span>
                        <span class="comment-time">昨天 15:30</span>
                    </div>
                    <p class="comment-text">总部会提供哪些培训？培训周期是多久？是否需要到总部参加培训？</p>
                    <div class="comment-actions">
                        <button class="comment-action">
                            <i class="far fa-thumbs-up"></i>
                            <span>8</span>
                        </button>
                        <button class="comment-action reply-btn">
                            <i class="far fa-reply"></i>
                            <span>回复</span>
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- 评论3 -->
            <div class="comment-item">
                <img src="https://picsum.photos/id/65/100/100" alt="用户头像" class="user-avatar">
                <div class="comment-content">
                    <div class="comment-header">
                        <span class="user-name">奶茶店老板</span>
                        <span class="comment-time">3天前</span>
                    </div>
                    <p class="comment-text">我现在有一家奶茶店，想在店里增加咖啡品类，这种情况可以加盟吗？</p>
                    <div class="comment-actions">
                        <button class="comment-action active">
                            <i class="far fa-thumbs-up"></i>
                            <span>23</span>
                        </button>
                        <button class="comment-action reply-btn">
                            <i class="far fa-reply"></i>
                            <span>回复</span>
                        </button>
                    </div>
                    
                    <!-- 回复 -->
                    <div class="replies-container">
                        <div class="reply-item">
                            <div class="reply-header">
                                <span class="user-name">醇香咖啡官方</span>
                                <span class="comment-time">2天前</span>
                            </div>
                            <p class="reply-text">您好，我们目前只接受独立门店加盟，不支持在现有店铺中增设品类，感谢您的关注！</p>
                            <div class="reply-actions">
                                <button class="reply-action">
                                    <i class="far fa-thumbs-up"></i>
                                    <span>3</span>
                                </button>
                                <button class="reply-action">
                                    <i class="far fa-reply"></i>
                                    <span>回复</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 加载更多评论 -->
        <button class="btn btn-light w-100" style="font-size: 14px; padding: 8px;">
            查看更多评论
        </button>
    </div>
    
    <!-- 操作按钮 -->
    <div class="action-buttons">
        <button class="action-btn secondary-btn">
            <i class="far fa-heart"></i>
            <span>收藏</span>
        </button>
        <button class="action-btn secondary-btn">
            <i class="far fa-share-square"></i>
            <span>分享</span>
        </button>
        <button class="action-btn secondary-btn">
            <i class="far fa-phone"></i>
            <span>电话咨询</span>
        </button>
        <button class="action-btn primary-btn">
            <i class="fas fa-comment-dots"></i>
            <span>在线咨询</span>
        </button>
    </div>
    
    <!-- 底部导航 -->
    <div class="bottom-nav">
        <a href="#" class="nav-item">
            <i class="fas fa-home nav-icon"></i>
            <span>首页</span>
        </a>
        <a href="#" class="nav-item active">
            <i class="fas fa-handshake nav-icon"></i>
            <span>招商</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-bell nav-icon"></i>
            <span>消息</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-user nav-icon"></i>
            <span>我的</span>
        </a>
    </div>
    
    <!-- 图片查看器 -->
    <div class="image-viewer" id="imageViewer">
        <button class="close-viewer" id="closeViewer">
            <i class="fas fa-times"></i>
        </button>
        <div class="viewer-count" id="viewerCount">1/3</div>
        <img src="" alt="图片查看" class="viewer-image" id="viewerImage">
    </div>
    
    <!-- 提示消息 -->
    <div class="toast" id="toast"></div>
    
    <!-- Bootstrap JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // DOM元素
        const backBtn = document.getElementById('backBtn');
        const shareBtn = document.getElementById('shareBtn');
        const carousel = document.getElementById('detailCarousel');
        const carouselInner = document.getElementById('carouselInner');
        const carouselCount = document.getElementById('carouselCount');
        const imageViewer = document.getElementById('imageViewer');
        const viewerImage = document.getElementById('viewerImage');
        const viewerCount = document.getElementById('viewerCount');
        const closeViewer = document.getElementById('closeViewer');
        const toast = document.getElementById('toast');
        const commentActions = document.querySelectorAll('.comment-action');
        const replyBtns = document.querySelectorAll('.reply-btn');
        const actionButtons = document.querySelectorAll('.action-btn');
        
        // 图片数据
        const images = [
            'https://picsum.photos/id/292/800/400',
            'https://picsum.photos/id/431/800/400',
            'https://picsum.photos/id/766/800/400'
        ];
        
        let currentImageIndex = 0;
        
        // 初始化
        function init() {
            // 初始化轮播图
            const carouselInstance = new bootstrap.Carousel(carousel, {
                interval: 3000,
                wrap: true
            });
            
            // 轮播图切换时更新计数
            carousel.addEventListener('slid.bs.carousel', function() {
                const activeIndex = Array.from(carouselInner.children).findIndex(item => 
                    item.classList.contains('active')
                );
                carouselCount.textContent = `${activeIndex + 1}/${images.length}`;
                currentImageIndex = activeIndex;
            });
            
            // 绑定事件
            bindEvents();
        }
        
        // 绑定事件
        function bindEvents() {
            // 返回按钮
            backBtn.addEventListener('click', () => {
                history.back();
            });
            
            // 分享按钮
            shareBtn.addEventListener('click', () => {
                showToast('分享功能已触发');
            });
            
            // 轮播图点击查看大图
            carouselInner.addEventListener('click', () => {
                openImageViewer(currentImageIndex);
            });
            
            // 关闭图片查看器
            closeViewer.addEventListener('click', () => {
                imageViewer.classList.remove('active');
                document.body.style.overflow = 'auto';
            });
            
            // 图片查看器滑动切换
            let startX = 0;
            imageViewer.addEventListener('touchstart', (e) => {
                startX = e.touches[0].clientX;
            });
            
            imageViewer.addEventListener('touchend', (e) => {
                const endX = e.changedTouches[0].clientX;
                const diffX = endX - startX;
                
                if (Math.abs(diffX) > 50) {
                    if (diffX > 0) {
                        // 向右滑动，上一张
                        currentImageIndex = (currentImageIndex - 1 + images.length) % images.length;
                    } else {
                        // 向左滑动，下一张
                        currentImageIndex = (currentImageIndex + 1) % images.length;
                    }
                    updateImageViewer();
                }
            });
            
            // 评论点赞
            commentActions.forEach(action => {
                if (action.querySelector('.far.fa-thumbs-up')) {
                    action.addEventListener('click', function() {
                        this.classList.toggle('active');
                        const countElem = this.querySelector('span');
                        let count = parseInt(countElem.textContent);
                        
                        if (this.classList.contains('active')) {
                            countElem.textContent = count + 1;
                            this.innerHTML = '<i class="fas fa-thumbs-up"></i><span>' + (count + 1) + '</span>';
                        } else {
                            countElem.textContent = count - 1;
                            this.innerHTML = '<i class="far fa-thumbs-up"></i><span>' + (count - 1) + '</span>';
                        }
                    });
                }
            });
            
            // 回复按钮点击
            replyBtns.forEach(btn => {
                btn.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const replyInput = this.closest('.comment-item') || this.closest('.reply-item')
                        ? this.closest('.comment-content').querySelector('.reply-input')
                        : null;
                    
                    if (replyInput) {
                        replyInput.focus();
                    }
                });
            });
            
            // 操作按钮点击
            actionButtons.forEach(btn => {
                btn.addEventListener('click', function() {
                    const text = this.querySelector('span').textContent;
                    showToast(`${text}功能已触发`);
                    
                    // 收藏按钮切换状态
                    if (this.querySelector('.far.fa-heart')) {
                        this.classList.toggle('active');
                        if (this.classList.contains('active')) {
                            this.innerHTML = '<i class="fas fa-heart"></i><span>已收藏</span>';
                        } else {
                            this.innerHTML = '<i class="far fa-heart"></i><span>收藏</span>';
                        }
                    }
                });
            });
        }
        
        // 打开图片查看器
        function openImageViewer(index) {
            currentImageIndex = index;
            updateImageViewer();
            imageViewer.classList.add('active');
            document.body.style.overflow = 'hidden';
        }
        
        // 更新图片查看器
        function updateImageViewer() {
            viewerImage.src = images[currentImageIndex];
            viewerCount.textContent = `${currentImageIndex + 1}/${images.length}`;
        }
        
        // 显示提示消息
        function showToast(message) {
            toast.textContent = message;
            toast.classList.add('show');
            
            clearTimeout(toast.timeout);
            toast.timeout = setTimeout(() => {
                toast.classList.remove('show');
            }, 2000);
        }
        
        // 初始化
        init();
    </script>
</body>
</html>
